  var operationRecord = {
		    init: function () {
		        this.bindquery();
		        this.tempAlarmType = alarmType;
		        this.queryDetail('.queryAlarm', '#senior', 41, function (height) {
		            var flexIgridH = nav.whiceH[1] - 112 - height + 30 + 'px';
		            $('#queryResult').flexResize('auto', flexIgridH);
		        });
		        /** 初始化日期 * */
/*		        var date = new Date();
		        $("#inputStartDate").val(global.getToday(date));
		        $("#inputEndDate").val(global.getTime(date));*/
		        this.operationRecord();
		    },

		    /**
		     * 导出操作记录
		     */
		    exportSimCard: function () {
		    	
		        var options = $("#queryResult").getOptions();
		        var total = options.total;
		        if (total == 0) {
		            global.ajaxLoading.pop("无导出数据", false, 2000);
		            return;
		        }
		        var pages = options.pages;
		        //设置默认的开始结束页
		        $("#StartPageIndex").val(1);
		        $("#EndPageIndex").val(pages);
		        //显示导出窗口
		        $("#exportModal").modal('show');
		    },
		    getColumn: function () {
		    	
		        var operationTime = function(operationTime){
		        	var time = global.getTime(new Date(JSON.parse(operationTime)));
		        	var string = '<span>'+time+'</span>';
		        	return string;
		        };
		        function formatSimCard(data) {
		            var time = "";
		            if (data != "") {
		                console.log(data + "-" + typeof(data));
		                time = global.getTime(new Date(JSON.parse(data)));
		            }

		            var str = '<span>' + time + '</span>';
		            return str;
		        };
		        return [
		            {
		                display: '用户姓名',
		                name: 'userName',
		                width: 15,
		                sortable: false,
		                align: 'left',
		                checked: 'checked'
		            },
		            {
		                display: '模块名称',
		                name: 'moduleName',
		                width: 15,
		                sortable: false,
		                align: 'left',
		            },
		            {
		                display: '操作时间',
		                name: 'operationTime',
		                width: 15,
		                sortable: false,
		                align: 'left',
		                paramcolnames: ['operationTime'],
		                handlefunction: operationTime,
		            },
		            {
		                display: '日志描述',
		                name: 'operationDescribe',
		                width: 15,
		                sortable: false,
		                align: 'left',
		            }
		        ]
		    },
		    exportComfirm: function () {
		        var me = this;
		        var options = $("#queryResult").getOptions();
		        //总记录数
		        var total = options.total;
		        //开始页数
		        var StartPage = $("#StartPageIndex").val();
		        //结束页数
		        var EndPage = $("#EndPageIndex").val();
		        var validate = true;
		        var msg = "";
		        if (!StartPage || StartPage == 0) {
		            msg += "【起始页不能为空或者0】";
		            validate = false;
		        }
		        if (!EndPage || EndPage == 0) {
		            msg += "【结束页不能为空或者0】";
		            validate = false;
		        }

		        if (StartPage && EndPage && EndPage < StartPage) {
		            msg += "【结束页要大于起始页】";
		            validate = false;
		        }
		        if (!validate) {
		            global.ajaxLoading.pop(msg, false, 2000);
		            return;
		        }
		        $('#exportModal').modal('hide');
		        global.ajaxLoading.pop("正在导出,请稍后.....", true, 2000);
		        //每页大小
		        var pagesize = options.rp;
		        var exportParams = options.exportParams;
		        if ((EndPage - StartPage + 1) * pagesize > 60000 && total > 60000) {
		        	global.ajaxLoading.pop("最多只能导出60000条数据", true, 2000);
		            return
		        }
		        //每页大小
		        var pagesize = options.rp;
		        var getColumnCopy = JSON.parse(JSON.stringify(operationRecord.getColumn()));
		        var getColumnW = $('#historyAlarm').width();
		        for(var i=0;i<getColumnCopy.length;i++){
		        	getColumnCopy[i].width = parseInt(getColumnW / 100 * getColumnCopy[i].width);
		        }
		        console.log(getColumnCopy);
		        var header1 = JSON.stringify(getColumnCopy);
		        var colModelList = new Array();//表头
		        colModelList.push(header1);
		        var colModel = $.toJSON(colModelList);
		        var paramsGrid = {
		            queryParams:JSON.stringify(operationRecord.getparams()),
		            colModel: colModel,
		            title: "操作日志数据",
		            StartPage: StartPage,
		            EndPage: EndPage,
		            pagesize: pagesize
		        };
		        post(appCtx + "/log/OperationRecord/exportRecord.html", paramsGrid);
		    },
		    
		    
		    
		    bindquery: function () {
		        $("a[name='exportSimCardBtn']").bind('click', function () {
		            operationRecord.exportSimCard();
		        });
		        $("#confirmExport").click(function () {
		            operationRecord.exportComfirm();
		        })
		        var _this = this;
		        $('#queryAlarm').click(function () {
		            // 历史报警查询不能超过三天
		            var start = $("#inputStartDate").val().replace(/-/g, "/");
		            var end = $("#inputEndDate").val().replace(/-/g, "/");
		            if ((new Date(end).getTime() - new Date(start).getTime())
		                / (1000 * 60 * 60 * 24) > 30) {
		                global.ajaxLoading.pop("操作日志查询不能超过三天", false, 1000);
		                return;
		            }
		            $("#queryResult").flexOptions({
		                newp: 1,
		                params: operationRecord.getparams()
		            }).flexReload();
		        });
		        $('#dealAlarm').click(function () {
		            $('#handerHistoryContent').val("");
		            var vehicle = [];
		            var alarmType = [];
		            var alarmTime = [];
		            var alarmName = [];
		            $('#queryResult')
		                .find('.trSelected')
		                .each(
		                    function () {
		                        var tdArr = $(this).children();
		                        if (tdArr.eq(10).find('div')
		                                .html() == null
		                            || tdArr.eq(10).find(
		                                'div').html() == ''
		                            || tdArr.eq(10).find(
		                                'div').html() == '&nbsp;') {
		                            vehicle
		                                .push(tdArr
		                                    .eq(2)
		                                    .find('div')
		                                    .html());
		                            alarmType
		                                .push(tdArr
		                                    .eq(3)
		                                    .find('div')
		                                    .html());
		                            alarmTime
		                                .push(tdArr
		                                    .eq(9)
		                                    .find('div')
		                                    .html());
		                            alarmName
		                                .push(tdArr
		                                    .eq(6)
		                                    .find('div')
		                                    .html());
		                        }
		                    });

		            var vehicles = vehicle[0];
		            var alarmTypes = alarmType[0];
		            for (var i = 0; i < vehicle.length; i++) {
		                if (vehicle[i] != vehicles) {
		                    global.ajaxLoading
		                        .pop("车辆不一致", false, 1000);
		                    return;
		                }
		                if (alarmType[i] != alarmTypes) {
		                    global.ajaxLoading.pop("报警类型不一致", false,
		                        1000);
		                    return;
		                }
		            }
		            if (vehicle == null || vehicle == "") {
		                if ($('#queryResult').find('.trSelected')
		                        .size() > 0) {
		                    global.ajaxLoading.pop("你选择的报警数据已经处理",
		                        false, 1000);
		                    return;
		                } else {
		                    global.ajaxLoading
		                        .pop("请选择车辆", false, 1000);
		                    return;
		                }
		            }
		            $('#handlerhisAlarmTime').val(alarmTime);
		            $("#handlerhisVevhicleid").val(vehicles);
		            $("#handlerhisAlarmType").val(alarmTypes);
		            $("#showHistoryAlarmType").val(alarmName[0]);
		            operationRecord.queryoperationRecord();
		        });
		    },
		    
		    

			/**
			 * 日历的显示
			 */
		    queryDetail: function (showDome, clickDome, height, callback) {
		        $(clickDome).on('click', function () {
		            if ($(this).hasClass('active')) {
		                $(this).removeClass('active');
		                $(showDome).css('height', height);
		            } else {
		                $(this).addClass('active')
		                $(showDome).css('height', 'auto');
		            }
		            var h = $('#historyAlarm').height();
		            callback && callback(h);
		        })
		    },
		    /**
		     * 重新加载历史报警
		     */
		    reloadoperationRecord: function () {
		        var page = $("#queryResult").page;

		        $("#queryResult").flexOptions({
		            newp: page,
		            params: operationRecord.getparams()
		        }).flexReload();

		    },
		    /**
		     * 操作日志
		     */
		    operationRecord: function () {
		        $('body').on(
		            'click',
		            '.alarmHistoryDeal',
		            function () {
		                $('#handerHistoryContent').val("");
		                var vid = $(this).attr("vid");
		                var alarmType = $(this).attr("alarmkind");
		                var alarmTime = $(this).attr("alarmTime");
		                var params = {
		                    "VehicleID": vid,
		                    "AlarmType": alarmType,
		                    "alarmTime": alarmTime
		                };
		                $('#handlerhisAlarmTime').val(alarmTime), $(
		                    "#handlerhisVevhicleid").val(vid), $(
		                    "#handlerhisAlarmType").val(alarmType), $(
		                    "#showHistoryAlarmType").val(
		                    operationRecord.tempAlarmType.getAlarmName($(this).attr("alarmkind")));
		                operationRecord.queryoperationRecord();

		            });
		        $('body').on(
		            'click',
		            '.viewHisMap',
		            function () {
		                var vehilceID = $(this).attr("vehilceID");
		                var alarmType = $(this).attr("alarmType");
		                var alarmkind = $(this).attr("alarmkind");
		                var alarmTime = $(this).attr("alarmTime");
		                var lon = $(this).attr("lon");
		                var lat = $(this).attr("lat");
		                var head = $(this).attr("head");
		                var gpsSpeed = $(this).attr("gpsSpeed");
		                window.open(appCtx
		                    + 'alarm/history/location.html?vehicleID='
		                    + vehilceID + "&alarmType=" + alarmType
		                    + "&alarmTime=" + alarmTime + "&lon=" + lon
		                    + "&lat=" + lat + "&head=" + head + "&gpsSpeed="
		                    + gpsSpeed);
		            });
		        
		        
		        var operationTime = function(operationTime){
		        	var time = global.getTime(new Date(JSON.parse(operationTime)));
		        	var string = '<span>'+time+'</span>';
		        	return string;
		        };
		        var queryResult = function () {
		            $("#queryResult").flexigrid(
		                {
		                    dataType: 'json',
		                    url: appCtx + '/log/OperationRecord/getOperationRecord.html',
		                    params:operationRecord.getparams(),
		                    contentType: "application/json; charset=utf-8",
		                    method: 'POST',
		                    colModel: [
		           		            {
		        		                display: '用户姓名',
		        		                name: 'userName',
		        		                width: 20,
		        		                sortable: false,
		        		                align: 'left',
		        		                checked: 'checked'
		        		            },
		        		            {
		        		                display: '模块名称',
		        		                name: 'moduleName',
		        		                width: 20,
		        		                sortable: false,
		        		                align: 'left',
		        		            },
		        		            {
		        		                display: '操作时间',
		        		                name: 'operationTime',
		        		                width: 20,
		        		                sortable: false,
		        		                align: 'left',
		        		                paramcolnames: ['operationTime'],
		        		                handlefunction: operationTime,
		        		            },
		        		            {
		        		                display: '日志描述',
		        		                name: 'operationDescribe',
		        		                width: 20,
		        		                sortable: false,
		        		                align: 'left',
		        		            }
		                        ],

		                    resizable: false,
		                    sortname: "operationTime",// 第一次加载数据时排序列
		                    sortorder: "asc",// 第一次加载数据时排序类型
		                    usepager: true,// 是否分页，默认为true。
		                    showToggleBtn: false,
		                    showTableToggleBtn: false,// 是否显示收起/打开按钮,默认不显示。
		                    useRp: true,// 是否可以动态设置每页显示的结果数，默认为false。
		                    rp: 10,// 每页记录数，默认为10
		                    rpOptions: [10, 15, 20, 30, 50, 100, 300, 500], // 每页结果数
		                    // true时才有效。
		                    width: $('#historyAlarm').width(),// 表格宽度
		                    height: nav.whiceH[0] - 125, // 表格高度
		                    widthType : '%',
		                    titDisplay: false,
		                    onSuccess: function (data) {

		                    },
		                    onSelectRow: function (row) {

		                    },
		                    onSelectAllRow: function (data) {

		                    }
		                });
		        };
		        queryResult();
		    },
		    
		    getparams: function () {
		        var moduleName = $("#moduleName").val();
		        var startDate = $("#inputStartDate").val();
		        var endDate = $("#inputEndDate").val();
		        var pageSize = $("#pageSize").val();
		        var params = [{
		            name: 'moduleName',
		            value: moduleName
		        }, {
		            name: 'startTime',
		            value: startDate
		        }, {
		            name: 'endTime',
		            value: endDate
		        }];
		        return params;
		    },
		    marginRight:function(){
		    	var marginRight= $(document).width()-$(".quaryAllAlarm").width()-50-150+'px';
		    	if(marginRight>250){
		    		$('.quaryAllAlarm').css('margin-right',marginRight);
		    	}else{
//		    	 	$('.quaryAllAlarm').css('margin-right',"250px");
		    	}
		    }
  };
operationRecord.init();
